package others;

public class monotoneIncreasingDigits2 {
    public static int monotoneIncreasingDigits(int n) {

        String s = String.valueOf(n);
        int len=s.length()-1;
        int start=len;
        char[] chars = s.toCharArray();
        for (int i=len-2;i>=0;--i){
            if(chars[i]>=chars[i+1]){
                chars[i]--;
                start=i+1;

            }
        }
        for (int i=start;i<len;++i){
            chars[i]='9';
        }
        return Integer.parseInt(String.valueOf(chars));
    }



    public static void main(String[] args) {
        System.out.println();
    }
}
